package org.wangp.business.user.web.controller

import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*
import org.wangp.business.user.domain.OrderDTO
import org.wangp.business.user.domain.UserDTO
import org.wangp.business.user.service.UserService
import org.wangp.framework.core.domain.CommonResult
import org.wangp.framework.core.validate.Insert

/**
 * @author wangpeng (๑•ᴗ•๑)
 * @since 2021/10/2 10:40
 */
@RestController
@RequestMapping("user")
class UserController(
	private val userService: UserService
) {

	@PostMapping("register")
	fun registerUser(@RequestBody @Validated(value = [Insert::class]) userDTO: UserDTO): CommonResult<Void> {
		userService.addUser(userDTO)
		return CommonResult.success()
	}

	@GetMapping("searchOrders")
	fun searchOrders(): List<OrderDTO> {
		return userService.searchOrders()
	}
}
